package com.xbongbong.saas.service;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.pojo.FieldAttrEntityForImport;
import com.xbongbong.paas.pojo.dto.FormDataAddDTO;
import com.xbongbong.paas.pojo.dto.FormDataListDTO;
import com.xbongbong.paas.pojo.dto.ImportFormDataDTO;
import com.xbongbong.paas.pojo.dto.SaasFormSaveDTO;
import com.xbongbong.paas.pojo.dto.ValidateDataDTO;
import com.xbongbong.paas.pojo.imports.CellTitlePojo;
import com.xbongbong.paas.pojo.imports.RowGroupPojo;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.businessproduct.pojo.dto.BusinessProductListDTO;
import com.xbongbong.pro.businessproduct.pojo.vo.BusinessProductListVO;
import com.xbongbong.pro.detailtab.dto.DetailTabDataGetDTO;
import com.xbongbong.pro.detailtab.dto.SupplierProductAddDTO;
import com.xbongbong.pro.detailtab.vo.ProductSummaryVO;
import com.xbongbong.pro.formdata.pojo.AfterSavePojo;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;
import com.xbongbong.pro.listbatch.pojo.dto.AddLabelDTO;
import com.xbongbong.pro.product.pojo.dto.PagingProductDTO;
import com.xbongbong.pro.product.pojo.vo.PagingProductVO;
import com.xbongbong.pro.supplier.pojo.dto.SupplierDeleteBatchDTO;
import com.xbongbong.pro.supplier.pojo.dto.SupplierEditAttrUpdateDTO;
import com.xbongbong.pro.supplier.pojo.dto.SupplierUpdateBatchDTO;
import com.xbongbong.pro.supplier.pojo.dto.SupplierUpdateByBusinessRuleDTO;
import com.xbongbong.pro.supplier.pojo.vo.SupplierDeleteBatchVO;
import com.xbongbong.pro.supplier.pojo.vo.SupplierUpdateBatchVO;
import com.xbongbong.saas.domain.entity.SupplierProductEntity;
import com.xbongbong.saas.domain.entity.ext.SupplierEntityExt;
import com.xbongbong.saas.enums.UpdateDataTypeEnum;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 供应商service接口层
 * @author Jian.Wang
 * @date 2019/1/23 20:00
 * @since v1.0
 * @version v1.0
 */
public interface SupplierService {
    /**
     * 供应商保存前saas特殊校验
     *
     * @param validateDataDTO saas特殊校验数据入参
     * @author Jian.Wang
     * @date 2019/1/23 20:00
     * @since v1.0
     * @throws XbbException 异常
     **/
    void beforeSave(ValidateDataDTO validateDataDTO) throws XbbException;

    /**
     * 供应商保存后逻辑
     *
     * @param saasFormSaveDTO saas保存数据
     * @author Jian.Wang
     * @date 2019/1/23 20:00
     * @since v1.0
     * @throws XbbException 异常
     **/
    AfterSavePojo afterSave(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;

    void updateProductLinkSupplier(String corpid, Set<Long> influenceProductIdList) throws XbbException;

    void updateProductLinkSupplier(String corpid, SupplierProductEntity supplierProductEntity) throws XbbException;

    /**
     * 批量删除供应商
     * @author 吴峰
     * @date 2019/3/6 21:55
     * @param supplierDeleteBatchDTO
     * @return com.xbongbong.pro.supplier.pojo.vo.SupplierDeleteBatchVO
     * @throws XbbException 业务异常
     */
    SupplierDeleteBatchVO deleteBatch(SupplierDeleteBatchDTO supplierDeleteBatchDTO) throws XbbException;

    /**
     * 批量修改某个字段
     * @author 吴峰
     * @date 2019/3/19 11:18
     * @param supplierEditAttrUpdateDTO
     * @return void
     * @throws XbbException 业务异常
     */
    void batchEditAttr(SupplierEditAttrUpdateDTO supplierEditAttrUpdateDTO) throws XbbException;

    /**
     * 批量编辑
     * @author 吴峰
     * @date 2019/3/19 11:24
     * @param supplierUpdateBatchDTO
     * @return com.xbongbong.pro.supplier.pojo.vo.SupplierUpdateBatchVO
     * @throws XbbException 业务异常
     */
    SupplierUpdateBatchVO updateBatch(SupplierUpdateBatchDTO supplierUpdateBatchDTO) throws XbbException;

    /**
     * 获取供应商产品
     *
     * @param businessProductListDTO 入参
     * @param dataList data对象
     * @author chaoxiong.lei
     * @Date 14:37 2019/3/5
     * @since v1.0
     * @return BusinessProductListVO，属性product包含了关联产品，返回给前端的格式
     **/
//    BusinessProductListVO getSupplierProductList(BusinessProductListDTO businessProductListDTO, JSONObject dataList) throws XbbException;

    /**
     * 星级：将数字转成文字显示
     *
     * @param level 星级
     * @author GuoJun.HU
     * @since V1.0
     * @return String
     * @date 2019/3/22 10:15
     */
    String getLevelString(String level);

    /**
     * 将星级转成文字显示
     *
     * @param star 星级
     * @author GuoJun.HU
     * @since V1.0
     * @return String
     * @date 2019/4/4 15:35
     */
    String transferLevel2Chinese(Integer star);

    /**
     * 将Excel数据格式化成表单保存需要的JSON格式的数据
     *
     * @param importFormDataDTO 导入入参
     * @param titlePojoList     标题
     * @param rowGroupPojo      一个表单对应的一组Excel填写的数据
     * @param fieldAttrList     解释
     * @return FormDataAddDTO
     * @throws XbbException XbbException
     * @author GuoJun.HU
     * @date 2019/4/29 14:16
     * @since V1.0
     */
    FormDataAddDTO formatExcelValue(ImportFormDataDTO importFormDataDTO, List<CellTitlePojo> titlePojoList, RowGroupPojo rowGroupPojo, List<FieldAttrEntityForImport> fieldAttrList) throws XbbException;

    /**
     * 格式化导出值
     *
     * @param paasFormDataESList 数据
     * @throws XbbException 异常
     */
    void formatExportValue(List<PaasFormDataEntityExt> paasFormDataESList, FormDataListDTO formDataListDTO, List<FieldAttrEntityForImport> fieldAttrList) throws XbbException;

    /**
     * 汇总供应商产品信息（详情页，几种商品几件）
     *
     * @param businessProductListDTO 入参
     * @throws XbbException
     * @author long.rao
     * @date 2019-08-28 10:23
     */
    ProductSummaryVO summaryProductList(BusinessProductListDTO businessProductListDTO) throws XbbException;

    /**
     * 根据业务规则，更新供应商
     * @param supplierUpdateByBusinessRuleDTO
     * @throws XbbException
     */
    void updateBatchByBusinessRule(SupplierUpdateByBusinessRuleDTO supplierUpdateByBusinessRuleDTO) throws XbbException;

    void formatProduct4Show2(Long dataId, String corpid, JSONObject data, UpdateDataTypeEnum updateDataTypeEnum) throws XbbException;

    PagingProductVO getPagingProduct(PagingProductDTO pagingProductDTO) throws XbbException;

    /**
     * Description: 获取供应商名称集合
     * @param handoverIdSet
     * @param corpid
     * @author 刘阳
     * @date 2020/1/8 2:41 PM
     * @since v1.0
     */
    Map<Long, String> getSupplierNameMap(List<Long> handoverIdSet, String corpid) throws XbbException;

    /**
     * 供应商详情页添加产品数据校验
     *
     * @param validateDataDTO 入参
     * @author jiantao.xiong
     * @date 2020/4/28
     */
    void validateProductData(ValidateDataDTO validateDataDTO) throws XbbException;

    /**
     * 供应商详情页添加产品
     *
     * @param supplierProductAddDTO 入参
     * @param supplierEntityExt 供应商信息
     * @author jiantao.xiong
     * @date 2020/4/28
     */
    void addSupplierProduct(SupplierProductAddDTO supplierProductAddDTO, SupplierEntityExt supplierEntityExt) throws XbbException;

    Boolean verifyEditPermissions(DetailTabDataGetDTO detailTabDataGetDTO) throws XbbException;

    /**
     * 批量增删标签
     * @param addLabelDTO
     * @param addBatchList
     * @throws XbbException
     */
    void updateBatchLabelAttr(AddLabelDTO addLabelDTO, List<PaasFormDataEntityExt> addBatchList, Boolean addOrDelete) throws XbbException;

    void afterSaveForWorkflow(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;

    void afterSaveForUpdateWorkflow(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;
}
